package com.example.springboot.entity;

import com.example.springboot.entity.vo.PostVo;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.sql.Timestamp;
import java.time.LocalDateTime;

@Data
public class Post {
    private Integer id;
    private String content;
    private Integer authorId;
    private Integer categoryId;
    private String tags;
    private Timestamp updatedTime;
    private Timestamp publishedTime;
    private Integer status;
    private Integer views;
    private Integer likes;
    private Integer commentsCount;
    private Integer collectCount;
    private Integer articleType;
    private String cover;
    private String title;
    private String summary;
    public void updateUpdatedTime() {
        this.updatedTime = Timestamp.valueOf(LocalDateTime.now());
    }

    public void updatePublishedTime() {
        this.publishedTime = Timestamp.valueOf(LocalDateTime.now());
    }
    public PostVo toVo(){
        PostVo postVo = new PostVo();
        BeanUtils.copyProperties(this, postVo);
        return postVo;
    }
}
